﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using Business;

namespace Data
{
    public class DataStats
    {
        public DataStats()
        { 
        }

        public List<Auxiliar> getNrCommentsUser()
        {
            List<Auxiliar> sl = new List<Auxiliar>();
            Auxiliar aux = new Auxiliar();
            Connect c = new Connect();
            try
            {
                SqlConnection conn = c.connect("");
                SqlCommand command = conn.CreateCommand();
                command.CommandText = "SELECT * FROM NrCommentsUser";
                SqlDataReader leitor = command.ExecuteReader();
                while (leitor.Read())
                {
                    aux = new Auxiliar();
                    if (!leitor.IsDBNull(0))
                        aux.setUserId(Convert.ToInt16(leitor[0]));
                    if (!leitor.IsDBNull(1))
                        aux.setNrComments(Convert.ToInt16(leitor[1]));
                    sl.Add(aux);
                }
                leitor.Close();
                conn.Close();

            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return sl;
        }

    }
}
